{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# NetworkX"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "NetworkX is a Python language software package for the creation, manipulation, and study of the structure, dynamics, and function of complex networks.\n",
    "\n",
    "With NetworkX you can load and store networks in standard and nonstandard data formats, generate many types of random and classic networks, analyze network structure, build network models, design new network algorithms, draw networks, and much more.\n",
    "\n",
    "Library documentation: <a>https://networkx.github.io/</a>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "import networkx as nx\n",
    "G = nx.Graph()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# basic add nodes\n",
    "G.add_node(1)\n",
    "G.add_nodes_from([2, 3])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# add a group of nodes at once\n",
    "H = nx.path_graph(10)\n",
    "G.add_nodes_from(H)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# add another graph itself as a node\n",
    "G.add_node(H)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# add edges using similar methods\n",
    "G.add_edge(1, 2)\n",
    "e = (2, 3)\n",
    "G.add_edge(*e)\n",
    "G.add_edges_from([(1, 2), (1, 3)])\n",
    "G.add_edges_from(H.edges())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# can also remove or clear\n",
    "G.remove_node(H)\n",
    "G.clear()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# repeats are ignored\n",
    "G.add_edges_from([(1,2),(1,3)])\n",
    "G.add_node(1)\n",
    "G.add_edge(1,2)\n",
    "G.add_node('spam')       # adds node \"spam\"\n",
    "G.add_nodes_from('spam') # adds 4 nodes: 's', 'p', 'a', 'm'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(8, 2)"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# get the number of nodes and edges\n",
    "G.number_of_nodes(), G.number_of_edges()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{2: {}, 3: {}}"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# access graph edges\n",
    "G[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{}"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "G[1][2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# set an attribute of an edge\n",
    "G.add_edge(1,3)\n",
    "G[1][3]['color'] = 'blue'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(1, 2, 0.125)\n",
      "(2, 1, 0.125)\n",
      "(3, 4, 0.375)\n",
      "(4, 3, 0.375)\n"
     ]
    }
   ],
   "source": [
    "FG = nx.Graph()\n",
    "FG.add_weighted_edges_from([(1, 2, 0.125), (1, 3, 0.75), (2, 4, 1.2), (3, 4, 0.375)])\n",
    "for n, nbrs in FG.adjacency_iter():\n",
    "    for nbr, eattr in nbrs.items():\n",
    "        data = eattr['weight']\n",
    "        if data < 0.5: print('(%d, %d, %.3f)' % (n, nbr, data))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'day': 'Friday'}"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# graph attribte\n",
    "G = nx.Graph(day='Friday')\n",
    "G.graph"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'day': 'Monday'}"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# modifying an attribute\n",
    "G.graph['day'] = 'Monday'\n",
    "G.graph"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[(1, {'room': 714, 'time': '5pm'}), (3, {'time': '2pm'})]"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# node attributes\n",
    "G.add_node(1, time='5pm')\n",
    "G.add_nodes_from([3], time='2pm')\n",
    "G.node[1]['room'] = 714\n",
    "G.nodes(data=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# edge attributes (weight is a special numeric attribute)\n",
    "G.add_edge(1, 2, weight=4.7)\n",
    "G.add_edges_from([(3, 4), (4, 5)], color='red')\n",
    "G.add_edges_from([(1, 2 ,{'color': 'blue'}), (2, 3, {'weight' :8})])\n",
    "G[1][2]['weight'] = 4.7\n",
    "G.edge[1][2]['weight'] = 4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.5"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# directed graph\n",
    "DG = nx.DiGraph()\n",
    "DG.add_weighted_edges_from([(1, 2 ,0.5), (3, 1, 0.75)])\n",
    "DG.out_degree(1, weight='weight')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1.25"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "DG.degree(1, weight='weight')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[2]"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "DG.successors(1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[3]"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "DG.predecessors(1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# convert to undirected graph\n",
    "H = nx.Graph(G)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": [
       "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\n"
      ],
      "text/plain": [
       "<matplotlib.figure.Figure at 0x12e9e320>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# basic graph drawing capability\n",
    "%matplotlib inline\n",
    "import matplotlib.pyplot as plt\n",
    "nx.draw(G)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
